

#ifndef _SIMULACION_H

#define _SIMULACION_H

#if defined (_WIN32)
#include "./Pthreads/include/pthread.h"
#endif

#include "Enumeraciones.h"
#include "ObjetoDeformable.h"
#include "ObjetoRigido.h"
#include "Laparoscopio.h"
#include "Intrumento_Qco.h"
#include "polhemusControl.h"
#include "ControlTimer.h"
#include "USBInstrumentoControl.h"


class Simulacion
{
public:
	//Constructor
	Simulacion();
	Simulacion(double TimeStep, char *filenamePuntosOrg, char *filenameIndicesOrg,
		char **filenamePuntosInstrumento1, char **filenameIndicesInstrumento1, int NumeroMallas1,
		char **filenamePuntosInstrumento2, char **filenameIndicesInstrumento2, int NumeroMallas2);

	//Propiedades
	void setTimeStep(double timestep){dblTimeStep = timestep;}
	double getTimeStep(){return dblTimeStep;}

	void setFnamePtosOrg(char *filename){charFnamePtosOrg = filename;}
	void setFnameIndsOrg(char *filename){charFnameIndsOrg = filename;}
	
	void setFnamePtosInst1(char **filename){charFnamePtosInst1 = filename;}
	void setFnameIndsInst1(char **filename){charFnameIndsInst1 = filename;}
	void setNroMallasInst1(int Mallas){intNroMallasInst1 = Mallas;}

	void setFnamePtosInst2(char **filename){charFnamePtosInst2 = filename;}
	void setFnameIndsInst2(char **filename){charFnameIndsInst2 = filename;}
	void setNroMallasInst2(int Mallas){intNroMallasInst2 = Mallas;}
	
	const int &getIDTriangColOrg1(){return intIDTriangColOrg1;}
	Triangulo &getTrianguloTemp1(){return objTrianguloTemp1;}

	const int &getIDTriangColOrg2(){return intIDTriangColOrg2;}
	Triangulo &getTrianguloTemp2(){return objTrianguloTemp2;}

	void setFnamePtosCubo(char *filename){charFnamePtosCubo = filename;}
	void setFnameIndsCubo(char *filename){charFnameIndsCubo = filename;}

	const int &getIDTriangColCubo1(){return intIDTriangColCubo1;}
	const int &getIDTriangColCubo2(){return intIDTriangColCubo2;}

	void setHayColisionInst1(bool bln1){blnHayColisionInst1 = bln1;}
	void setHayColisionInst2(bool bln2){blnHayColisionInst2 = bln2;}
	const bool &getHayColisionInst1(){return blnHayColisionInst1;}
	const bool &getHayColisionInst2(){return blnHayColisionInst2;}

	vector<Triangulo> &getTriangulosTempCubo1(){return objTriangulosTemp1Cubo;}
	vector<Triangulo> &getTriangulosTempCubo2(){return objTriangulosTemp2Cubo;}

	Triangulo &getOneTrianguloTempCubo1(int Nro){return objTriangulosTemp1Cubo[Nro];}
	Triangulo &getOneTrianguloTempCubo2(int Nro){return objTriangulosTemp2Cubo[Nro];}

	ObjetoDeformable &getOrgano(){return objHigado;}
	vector<ObjetoRigido> &getCubos(){return objCubos;}
	ObjetoRigido &getOneCubo(int intNro){return objCubos[intNro];}
	Laparoscopio getLaparoscopio(){return objLaparocopio;}
	Instrumento_Quirurgico &getInstrumentoQco1(){return objIntrumentoQco1;}
	Instrumento_Quirurgico &getInstrumentoQco2(){return objIntrumentoQco2;}

	void set_TipoSesion(TipoSesion enmSesion){enmTipoSesion = enmSesion;}

	void set_NumeroCubos(int Nro){intNumeroCubos = Nro;}
	int get_NumeroCubos(){return intNumeroCubos;}

	int get_IDCuboInst1(){return intIDCuboInst1;}
	int get_IDCuboInst2(){return intIDCuboInst2;}

	//Metodos
	void IncializarSimulacion();
	void PararSimulacion();
	void Simular();

	void ActualizarInstrumentos();

	Triangulo objTrianguloTemp1;
	Triangulo objTrianguloTemp2;

	vector<Triangulo> objTriangulosTemp1Cubo;
	vector<Triangulo> objTriangulosTemp2Cubo;

private:
	//Atributos
	double dblTimeStep;
	char *charFnamePtosOrg;
	char *charFnameIndsOrg;
	
	char **charFnamePtosInst1;
	char **charFnameIndsInst1;
	int intNroMallasInst1;

	char **charFnamePtosInst2;
	char **charFnameIndsInst2;

	int intNroMallasInst2;
	int intIDTriangColOrg1;
	int intIDTriangColOrg2;

	char *charFnamePtosCubo;
	char *charFnameIndsCubo;
	int intIDTriangColCubo1;
	int intIDTriangColCubo2;
	int intNumeroCubos;
	int intIDCuboInst1;
	int intIDCuboInst2;

	bool blnHayColisionInst1;
	bool blnHayColisionInst2;

	TipoSesion enmTipoSesion;

//#if defined(_WIN32)
	polhemusControl objPolhemusControl;
//#endif

	ObjetoDeformable objHigado;
	vector<ObjetoRigido> objCubos; 
	Laparoscopio objLaparocopio;
	Instrumento_Quirurgico objIntrumentoQco1;
	Instrumento_Quirurgico objIntrumentoQco2;
	ControlTimer objControlTimer;
	USBInstrumentoControl objUSBInstrumentoControl;
};

#endif


